/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.university.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.TreeEntity;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;

/**
 * 组织机构Entity
 * @author 朱俊吉
 * @version 2017-12-16
 */
public class UniversityOrg extends TreeEntity<UniversityOrg> {
	
	private static final long serialVersionUID = 1L;
	private UniversityOrg parent;		// 上级机构
	private String name;		// 名称
	private Integer sort;		// 序号
	private String code;		// 编号
	private String type;		// 机构类型
	private String grade;		// 机构等级
	
	public UniversityOrg() {
		super();
	}

	public UniversityOrg(String id){
		super(id);
	}

	public UniversityOrg(String id, String name) {
		super(id);
		this.name = name;
	}

	@JsonBackReference
	public UniversityOrg getParent() {
		return parent;
	}

	public void setParent(UniversityOrg parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=255, message="名称长度必须介于 0 和 255 之间")
	@ExcelField(title="名称", type=0, align=2, sort=1)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	@Length(min=0, max=255, message="编号长度必须介于 0 和 255 之间")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	@Length(min=0, max=5, message="机构类型长度必须介于 0 和 5 之间")
	@ExcelField(title="机构类型", type=0, align=2, sort=20, dictType="university_org_type")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Length(min=0, max=5, message="机构等级长度必须介于 0 和 5 之间")
	@ExcelField(title="机构等级", type=0, align=2, sort=30, dictType="university_org_grade")
	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
	
	@ExcelField(title="备注", type=0, align=2, sort=40)
	public String getRemarks() {
		return this.remarks;
	}
	
	@Length(min=1, max=2000)
	@ExcelField(title="上级机构", type=0, align=2, sort=10)
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
}